﻿using Core.Log;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Blog.Quartz.Application.Quartz.Timer
{
    public class LogJob
    {
        /// <summary>
        /// 删除程序运行的supervisor日志
        /// </summary>
        public void DeleteRunLog()
        {
            string[] programNames = { "BlogAdmin", "BlogAuthApi", "BlogFileApi", "BlogGateway", "BlogQuartzWeb", "BlogSmsApi", "BlogWebApi" };
            string[] allFiles = Directory.GetFiles("/var/log/");
            foreach (string name in programNames)
            {
                string[] files = allFiles.Where(s => s.Contains(name)).ToArray();
                foreach (string fileName in files)
                {
                    if (File.Exists(fileName))
                        File.Delete(fileName);
                }
            }
        }
    }
}
